<script>
    var items = <?= $items; ?>;
    var preview = <?= isset($_GET['preview']) ? 1 : 0; ?>;
</script>

<? if (count($results) > 0): ?>

<div id="filter" class="frm_color box">
    
    <span><?= lang('filter.title'); ?></span>

    <div class="srFiltersContent">

        <div class="collapse-filter accordion filtersList">

            <span><?= lang('filter.price_by_night'); ?></span>


            <div class="filteroptions" id="filter_price">

                <? if (isset($unique_prices['0,50'])): ?>

                <a data-category="filter_price" data-id="0,50" class="filterelement inactive" href="javascript:" rel="nofollow">

                    <div class="filter_item clearfix"><span><?= currency_sign() ?>&nbsp;0 - <?= currency_sign() ?>&nbsp;<?= ceil($rate * 49) ?></span> (<?= $unique_prices['0,50']->cnt ?>)</div>

                </a>

                <? endif; ?>

                <? if (isset($unique_prices['50,100'])): ?>
                <a data-category="filter_price" data-id="50,100" class="filterelement inactive" href="javascript:" rel="nofollow">

                    <div class="filter_item clearfix"><span><?= currency_sign() ?>&nbsp;<?= ceil($rate * 50) ?> - <?= currency_sign() ?>&nbsp;<?= ceil($rate * 99) ?></span> (<?= $unique_prices['50,100']->cnt ?>)</div>

                </a>
                <? endif; ?>

                <? if (isset($unique_prices['100,150'])): ?>
                <a data-category="filter_price" data-id="100,150" class="filterelement inactive" href="javascript:" rel="nofollow">

                    <div class="filter_item clearfix"><span><?= currency_sign() ?>&nbsp;<?= ceil($rate * 100) ?> - <?= currency_sign() ?>&nbsp;<?= ceil($rate * 149) ?></span> (<?= $unique_prices['100,150']->cnt ?>)</div>

                </a>
                <? endif; ?>

                <? if (isset($unique_prices['150,200'])): ?>
                <a data-category="filter_price" data-id="150,200" class="filterelement inactive" href="javascript:" rel="nofollow">

                    <div class="filter_item clearfix"><span><?= currency_sign() ?>&nbsp;<?= ceil($rate * 150) ?> - <?= currency_sign() ?>&nbsp;<?= ceil($rate * 199) ?></span> (<?= $unique_prices['150,200']->cnt ?>)</div>

                </a>
                <? endif; ?>

                <? if (isset($unique_prices['200,-1'])): ?>
                <a data-category="filter_price" data-id="200,-1" class="filterelement inactive" href="javascript:" rel="nofollow">

                    <div class="filter_item clearfix"><span><?= currency_sign() ?>&nbsp;<?= ceil($rate * 200) ?> +</span> (<?= $unique_prices['200,-1']->cnt ?>)</div>

                </a>
                <? endif; ?>

            </div>






            <span><?= lang('filter.star_rating'); ?></span>


            <div class="filteroptions" id="filter_stars">

                <?
                foreach ($unique_stars as $key => $value):
                if ($key != 0):
                ?>

                <a data-category="filter_stars" data-id="<?= $key ?>" class="filterelement inactive" href="javascript:" rel="nofollow">

                    <div class="filter_item clearfix"><span><?= $key ?> <?= $key == 1 ? lang('filter.star') : lang('filter.stars') ?></span> (<?= $value ?>)</div>

                </a>

                <?
                endif;
                endforeach;
                ?>

                <? if (isset($unique_stars[0])): ?>

                <a data-category="filter_stars" data-id="0" class="filterelement inactive" href="javascript:" rel="nofollow">

                    <div class="filter_item clearfix"><span><?= lang('filter.unrated'); ?></span> (<?= $unique_stars[0] ?>)</div>

                </a>

                <? endif; ?>

            </div>



            <span><?= lang('filter.distances'); ?></span>


            <div class="filteroptions" id="filter_distances">

                <?
                $show_beach = FALSE;
                $show_center = FALSE;

                foreach ($results as $item) :

                if (isset($item->object_distance_from_the_sea) && $item->object_distance_from_the_sea != "")
                $show_beach = TRUE;

                if (isset($item->object_distance_from_the_center) && $item->object_distance_from_the_center != "")
                $show_center = TRUE;

                endforeach;
                ?>

                <? if ($show_beach): ?>
                <div>
                    <span><?= lang('filter.beach_within'); ?>:</span><span id="beach_distance" class="value-distance"><?= lang('filter.no_preference'); ?></span>

                    <div id="slider-distances-beach" class="slider" data-id="beach_distance"></div>

                </div>
                <? endif; ?>

                <? if ($show_center): ?>
                <div>
                    <span><?= lang('filter.center_within'); ?>:</span><span id="center_distance" class="value-distance"><?= lang('filter.no_preference'); ?></span>
                    <div id="slider-distances-center" class="slider"  data-id="center_distance"></div>

                </div>
                <? endif; ?>



            </div>

            <span><?= lang('filter.facilities_services'); ?></span>

            <div class="filteroptions" id="filter_facilities_services">

                <?
                if (isset($unique) && count($unique) > 0)
                foreach ($unique as $attribute):
                ?>

                <a data-category="filter_facilities" data-id="<?= $attribute->id ?>" class="filterelement inactive" href="javascript:" rel="nofollow">

                    <div class="filter_item clearfix"><span><?= $attribute->title ?></span> (<?= $attribute->cnt ?>)</div>

                </a>

                <? endforeach; ?>

            </div>

        </div>

    </div>

</div>
<? endif; ?>